package com.example.mobile2032021606170hsy0507homework;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    private TextView tvMainTitle;
    private TextView tvMainEngine;
    private Button btnMainDetermine;
    private Button btnMainselect;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        btnMainselect.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this,EngineActivity.class);
                startActivityForResult(intent,1);
            }
        });
    }
    @Override
    protected  void onActivityResult (int requestCode, int resultCode, @Nullable Intent data){
        super.onActivityResult(resultCode,resultCode,data);
        if(requestCode==1&&requestCode==RESULT_OK){
            tvMainEngine.setText(data.getStringExtra("Engine"));
        }
    }


    private void initView() {
        tvMainTitle = (TextView) findViewById(R.id.tvMainTitle);
        tvMainEngine = (TextView) findViewById(R.id.tvMainEngine);
        btnMainDetermine = (Button) findViewById(R.id.btnMainDetermine);
        btnMainselect = (Button) findViewById(R.id.btnMainselect);
    }
}